/*
 * lib2Desa - Another 2D game library in C++
 * Copyright (C) 2009 Erivaldo Xavier de Lima Filho
 *
 * This program is free software and is distributed under GNU General Public License version 3. You can modify and/or redistribute
 * it under the terms of GPL version 3 or posterior version. This program comes with NO WARRANTY, for more details, see LICENSE,
 * or <http://www.gnu.org/licenses>.
 *
 * Contact info:
 *
 *	Erivaldo Xavier de Lima Filho, desadoc@gmail.com
 *
 */

#ifndef _APOSITIONABLE_HPP
#define _APOSITIONABLE_HPP

#include "Core/shared_ptr.hpp"
#include "Core/vector.hpp"

#ifndef _NO_NAMESPACE
namespace lib2Desa {
#endif

class APositionable
{

protected:

	vector3f pos;
	shared_ptr<APositionable> parent;

	APositionable(const shared_ptr<APositionable>& parent = null, const vector3f& pos = vector3f())
	{
		this->parent = parent;
		this->pos = pos;
	}

public:

	virtual ~APositionable(void){}

	void setParent(const shared_ptr<APositionable>& p)
	{
		parent = p;
	}

	const vector3f& getRelPos(void) const
	{
		return pos;
	}

	const vector3f getAbsPos(void) const
	{
		if(parent)
		{
			return (parent->getAbsPos() + this->getRelPos());
		}
		else
		{
			return this->getRelPos();
		}
	}

	void setRelPos(const vector3f& p)
	{
		pos = p;
	}
};

#ifndef _NO_NAMESPACE
}
#endif

#endif /*APositionable.hpp included*/
